﻿
using IDEAMS.core.deviceClient;
using IDEAMS.core.opm;
using IDEAMS.model.alarm;
using IDEAMS.model.device;
using System;

namespace IDEAMS.core
{
    public delegate void DelegateSyncAppClosed();
    public delegate void DelegateSyncReadChParameter(ReadChannelParameterResp resp);
    public delegate void DelegateSyncSettingChParameter();
    public delegate void DelegateSyncConnectionStatusChange(string serialNo, ConnectionStatus status);

    public delegate void DelegateSyncAlarm(AlarmInfo info);

    public delegate void DelegateSyncContinuousTime(string serialNo, double time);

    public delegate void DelegateSyncSendDeviceParam(DeviceParam deviceParam);

    public delegate void DelegateSyncSendDeviceFrequency(string serialNo, int frequency);

    public class DelegateCollection
    {
        public DelegateCollection() { }

        public DelegateSyncSendDeviceParam sendDeviceParamEvent;
        public void SyncSendDeviceParam(DeviceParam deviceParam)
        {
            if(sendDeviceParamEvent != null)
            {
                sendDeviceParamEvent(deviceParam);
            }
        }

        public DelegateSyncContinuousTime continuousTimeEvent;
        public void SyncContinuousTime(string serialNo, double time)
        {
            if(continuousTimeEvent != null)
            {
                continuousTimeEvent(serialNo, time);
            }
        }

        public DelegateSyncAlarm alarmEvent;
        public void SyncAlarm(AlarmInfo info)
        {
            if(alarmEvent != null)
            {
                alarmEvent(info);
            }
        }

        public DelegateSyncAppClosed appClosedEvent;
        public void SyncAppClosed()
        {
            if (appClosedEvent != null)
            {
                appClosedEvent();
            }
        }

        public DelegateSyncReadChParameter readChParameterEvent;
        public void SyncReadChParameter(ReadChannelParameterResp resp)
        {
            if (readChParameterEvent != null)
            {
                readChParameterEvent(resp);
            }
        }

        public DelegateSyncSettingChParameter settingChParameterEvent;
        public void SyncSettingChParameter()
        {
            if(settingChParameterEvent != null)
            {
                settingChParameterEvent();
            }
        }

        public DelegateSyncConnectionStatusChange connectionStatusChangeEvent;
        public void SyncConnectionStatusChange(string serialNo, ConnectionStatus status)
        {
            if (connectionStatusChangeEvent != null)
            {
                connectionStatusChangeEvent(serialNo, status);
            }
        }

        public DelegateSyncSendDeviceFrequency sendDeviceFrequencyEvent;
        public void SyncSendDeviceFrequency(string serialNo, int frequency)
        {
            if (sendDeviceFrequencyEvent != null)
            {
                sendDeviceFrequencyEvent(serialNo, frequency);
            }
        }
    }
}
